It may seem cleaner to omit keywords from your method declarations, but this is one time you should err on the side of verbosity. Omitting keywords
in a declaration necessarily means that they’ll be omitted from calls too. What results is code that will be impenetrable to maintainers. That’s why
it’s considered best practice to always use keywords. This applies both to Objective-C-style parameters without keywords, and to C-style parameter
declarations, which are deprecated.
Noncompliant code example
@interface MyAction
- (void)sendAction:(int)anAction :(int)flag; // Noncompliant
- (void)seekAction:(int)anAction, int flag; // Noncompliant; hard on maintainers AND deprecated
@end
void test(MyAction* myAction) {
[myAction sendAction:1 :1];
[myAction sendAction:1 forAllCells:1]; // warning: 'MyAction' may not respond to 'sendAction:forAllCells:'
[myAction seekAction:1 :1];
}
Compliant solution
@interface MyAction
- (void)sendAction:(int)anAction forAllCells:(int)flag;
- (void)seekAction:(int)anAction forAllCells:(int)flag;
@end
void test(MyAction* myAction) {
[myAction sendAction:1 forAllCells:1];
[myAction seekAction:1 forAllCells:1];
}